/* Sample app.js */


function main() {
	
	/* Main Function */
	
	var request = new XMLHttpRequest();
	
	request.open("GET", "http://two.axcid.org/mashup_api/?title=What+I+Got&artist=sublime", false);
	
	request.send(null);
	
	request.onreadystatechange = function () {
		
		/* Parse out the tracks */
		
		var tracksArray = request.responseXML.getElementsByTagName("track");
		var tracksCount = tracksArray.length;
		
		for(i=0;i<tracksCount;i++) {
			
			var SongName = tracksArray[i].childNodes[1].firstChild.nodeValue;
			var SongArtist = tracksArray[i].childNodes[2].firstChild.nodeValue
			var SongURL = tracksArray[i].childNodes[3].firstChild.nodeValue;
			
			AddToConsole("Song "+SongName+" by:"+SongArtist+" is downloadable at: "+SongURL);
			
		}
		
	}
	
}

function AddToConsole(text) {
	out.println(text);
}
